<?php
$q=$_GET["q"];
$hint='';
if($q!="")
{
include_once ("../Login/databaseconnection.php");
require_once ("../Login/config.php");
$result = mysql_query("SELECT * FROM competitions Where Competition_Name='$q'");
if($row = mysql_fetch_array($result))
{
$id=$row['Competition_Id'];
$hint="<br/><font color='black'>The ID of this Competition is :".$id."<br/>";
$resultpp= mysql_query("SELECT * FROM competition Where Competition_Id='$id'");
if($rowpp = mysql_fetch_array($resultpp))
{
$hint=$hint.'<br/>To view all <a href="'.$basedir.'/Competition/SeachCom.php?action=competition&c='.$id.'" class="searchlinks">'.$q.'</a> Competition details<br/>';
}
$resultds = mysql_query("SELECT DISTINCT(School_Id) FROM competition Where Competition_Id='$id'");
while($rowds= mysql_fetch_array($resultds))
{
$Sc=$rowds['School_Id'];
$hint=$hint."<br/>To view all ".$q." Competition details of ";
$resultsc = mysql_query("SELECT * FROM school Where School_Id='$Sc'");
$hint=$hint.'<a href="'.$basedir.'/Competition/SeachCom.php?action=school&s='.$rowds['School_Id'].'&c='.$id.'" class="searchlinks">';
if(mysql_num_rows($resultsc)==0)
{
$hint=$hint.$Sc;
}
if(mysql_num_rows($resultsc)>0)
{
if($rowsc= mysql_fetch_array($resultsc))
{
$hint=$hint.$rowsc['Name'].' in '.$rowsc['Address'];
}
}
$hint=$hint.'</a><br/>';
}
$resultdy = mysql_query("SELECT DISTINCT(Date) FROM competition Where Competition_Id='$id'");
while($rowdy= mysql_fetch_array($resultdy))
{
$hint=$hint."<br/>To view all ".$q." Competition details on ";
$hint=$hint.'<a href="'.$basedir.'/Competition/SeachCom.php?action=date&c='.$id.'&d='.$rowdy['Date'].'" class="searchlinks">'.$rowdy['Date'].'</a><br/>';
}
/*
$resultp = mysql_query("SELECT * FROM competition Where Competition_Id='$id'");
while($rowp= mysql_fetch_array($resultp))
{
$S_Id=$rowp['School_Id'];
$date=$rowp['Date'];

$results = mysql_query("SELECT * FROM school Where School_Id='$S_Id'");
if($rows= mysql_fetch_array($results))
{
$S_Name=$rows['Name'];
$S_Addr=$rows['Address'];
$C_No=$rows['Census_Number'];
}
$hint=$hint."<br/>To view the ".$q." Competition details of ";
$hint=$hint.'<a href="'.$basedir.'/Competition/SeachCom.php?action=competitionwithschoolanddate&s='.$S_Id.'&c='.$id.'&d='.$date.'" class="searchlinks">'.$S_Name.' in '.$S_Addr.', Census number '.$C_No.' at '.$date.'</a><br/>';
}
*/
$hint=$hint.'</font>';
}
}
if($hint==''||$hint=="<br/><font color='black'>The ID of this Competition is :".$id."<br/></font>")
{
echo $hint."<br/>";
$response='<font class="err"><img src="../images/alert.jpg" width="12" height="12"/> There are no results found for this Competition name!</font>';
}
else
{
$response=$hint;
}
echo $response;
?>